﻿using System;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using ProjScan.ScanRule.Attr;
using ProjScan.Submodules.CS_Check;

namespace ProjScan.ScanRule.CodeAnalysis
{
	// Token: 0x0200021D RID: 541
	[CSCheckRuleAttr]
	internal class NewObjInUpdate : InstructionRuleImpBase
	{
		// Token: 0x06000F62 RID: 3938 RVA: 0x00044848 File Offset: 0x00042A48
		protected override bool AnalyzeInst(MethodDefinition method, Instruction inst, ref LineMapping failedInfo)
		{
			bool flag = Enumerable.Contains<string>(this.CheckFunctionNames, method.Name) && inst.OpCode == OpCodes.Newobj;
			if (flag)
			{
				MethodReference methodReference = inst.Operand as MethodReference;
				bool flag2 = !methodReference.DeclaringType.Resolve().IsValueType;
				if (flag2)
				{
					failedInfo.Merge(LineMapping.GetMapping(method, inst));
					return false;
				}
			}
			return true;
		}

		// Token: 0x04000901 RID: 2305
		private string[] CheckFunctionNames = new string[]
		{
			"Update",
			"LateUpdate",
			"FixedUpdate"
		};
	}
}
